<template>
  <div>
     <!-- <topTable :columns='columns' :table-data='tableData' :handleCurrentChange='handleCurrentChanges'></topTable>       -->
      <el-table :data="tableData" @row-click='handleCurrentChanges' style="width: 100%"  highlight-current-row>
        <el-table-column
          label="ID"
          prop="index">
        </el-table-column>
        <el-table-column  :label="$t('message.systems.exist')" >
        <template  slot-scope="scope">   
          <span>{{scope.row.exist?$t('message.yes'):$t('message.no') }}</span>
        </template> 
      </el-table-column>
      </el-table>  
    <setForm id="2"  v-show="isShowPatition">       
       <template slot="boxTop">{{$t('message.systems.storageInfo')}}</template>
          <template slot="boxMain">   
           <el-table :data="patition" height="320"  style="width: 100%">
                 <el-table-column  :label="$t('message.name')" >
                  <template  slot-scope="scope">   
                    <span>{{$t('message.file.' + scope.row.name.split('.')[scope.row.name.split('.').length -1] )}}</span>
                  </template> 
                </el-table-column>
                <el-table-column
                  :label="$t('message.systems.patition')"
                  prop="patition">
                </el-table-column>
                <el-table-column
                  :label="$t('message.systems.mountPath')"
                  prop="mountPath">
                </el-table-column>
                <el-table-column
                  :label="$t('message.systems.type')"
                  prop="type">
                </el-table-column>
                <el-table-column  :label="$t('message.systems.totalSize')" >
                  <template  slot-scope="scope">   
                    <span>{{scope.row.totalSize /1024 /1024 }}</span>
                  </template> 
                </el-table-column>
                <el-table-column  :label="$t('message.systems.freeSize')" >
                  <template  slot-scope="scope">                       
                    <span>{{parseFloat(scope.row.freeSize /1024 /1024).toFixed(2)  }}</span>
                  </template> 
                </el-table-column>
              </el-table>  
          </template>
    </setForm>
  </div>
</template>

<script>
import setForm from "@/components/setForm";
import topTable from "@/components/topTable";
import mylist from "@/components/MyList";
import { mapState } from "vuex";
import ebus from "../../../../libs/ebus";
export default {
  created() {
    ebus.emit("getDiskInfo", this);
    if (
      this.system.diskInfo &&
      this.system.diskInfo.disks &&
      this.system.diskInfo.disks[0]
    ) {
      this.disk = this.system.diskInfo.disks[0];
    }
  },
  computed: {
    ...mapState(["system"]),
    isShowPatition(){      
      return this.currentRow.exist 
    },
    tableData() {
      var items = this.system.diskInfo.disks;

      return items;
    },
    diskInfos() {
      return this.currentRow.patitions;
    },
    patitions() {
      var items = [];
      if (this.currentRow.patitions) {
        items = this.currentRow.patitions;
      }      
      return items;
    }
  },
  data() {
    return {
      patition: [{
        index: 0
      }],
      currentRow: {},
      index: 0,
      sysTime: "",
      serverAddr: "",
      autoEnable: true,
      file: "",
      disk: "",
      list1: [
        { name: "名称", value: "名称" },
        { name: "MAC", value: "00:19:0f:20:35:fa" },
        { name: "序列号", value: "1bcfb46e-019d-11e8-b5ea-00190f2035fa" },
        { name: "条形码", value: "6901236377512" },
        { name: "模块名称", value: "MCN模块" },
        { name: "软件版本号", value: "V1.0" },
        { name: "硬件版本号", value: "V1.0" }
      ],
      columns: [
        {
          label: "ID",
          prop: "index"
        },
        {
          label: "exist",
          prop: "exist"
        }
      ],
      diskcolumns: [
        {
          label: "name",
          prop: "name"
        },
        {
          label: "patition",
          prop: "patition"
        },
        {
          label: "mountPath",
          prop: "mountPath"
        },
        {
          label: "type",
          prop: "type"
        },
        {
          label: "totalSize",
          prop: "totalSize"
        },
        {
          label: "freeSize",
          prop: "freeSize"
        }
      ]
    };
  },
  components: {
    setForm,
    mylist,
    topTable
  },
  methods: {
    handleCurrentChanges(val) {  
      // this.patition = []      
      if(val && val.patitions ){        
        this.patition = val.patitions
      }      
      this.currentRow = val;            
    }
  }
};
</script>

<style>

</style>

